import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isCollapse: false,
    user: undefined,
    posts:[]
  },
  getters: {
  },
  // 同步方法
  mutations: {
    setUserInfo(state,val){
      state.user = val
    },
    setPosts(state,val){
      state.posts = val
    },
  },
  // 异步方法
  actions: {
    setUserInfoAsync(context,val){
      context.commit('setUserInfo',val)
    },
    setPostsAsync(context,val){
      context.commit('setPosts',val)
    },
  },


  modules: {
  }
})
